package com.yand.DesignPattern.Singleton;

/**
 * 多数据源切换类
 * 
 * @Description: 多数据源切换类
 * @version 1.0
 * @since BWDA Audit 1.0
 * @author: shanxiaoming
 */
public class CustomerContextHolder {
    
    /**
     * 审计数据库
     */
    public static final String DATA_SOURCE_Audit = "dataSourceAudit";
    
    /**
     * 账号数据库
     */
    public static final String DATA_SOURCE_BWDA = "dataSourceBWDA";
    
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
    
    /**
     * 设定数据源
     * 
     * @param customerType 数据源类型
     */
    public static void setCustomerType(String customerType) {
        contextHolder.set(customerType);
    }
    
    public static String getCustomerType() {
        return contextHolder.get();
    }
    
    /**
     * 清除数据源
     */
    public static void clearCustomerType() {
        contextHolder.remove();
    }
}
